Laminar
Laminar is a semi-reliable UDP-based protocol for multiplayer games. This library implements wrappers around the UDP-protocol, and provides a lightweight, message-based interface which provides certain guarantees like reliability and ordering.
Laminar was designed to be used within the Amethyst game engine but is usable without it.
Concepts
This library is loosely based off of Gaffer on Games and shares features similar as RakNet, Steam Socket, netcode.io. The idea is to provide an in rust written, low-level UDP-protocol which supports the use of cases of video games that require multiplayer features. The library itself provides a few low-level types of packets that provide different types of guarantees. The most basic are unreliable and reliable packets. Also ordering, sequencing can be done on multiple streams. For more information, read the projects README.md, book, docs or examples.
Table of contents:
Features
These are the features this crate provides:
- UDP-based Protocol
- Connection Tracking
- Automatic Fragmentation
- Reliability Options: Unreliable and Reliable
- Arranging Options: Sequenced, Unordered, and Ordered.
- Arranging Streams
- Protocol Versioning
- RTT Estimation
- Link conditioner to simulate packet loss and latency
- Well-tested by integration and unit tests
Getting Stated
Add the laminar package to your Cargo.toml
file.
[]
= "0.2.3"
Useful Links
Examples
Please check out our examples for more information.
UDP API | see more
This is an example of how to use the UDP API.
Send packets
use ;
// create the socket
let = bind?;
// this will start the socket, which will start a poll mechanism to receive and send messages.
let _thread = spawn;
// our data
let bytes = vec!;
// You can create packets with different reliabilities
let unreliable = unreliable;
let reliable = reliable_unordered;
// We can specify on which stream and how to order our packets, checkout our book and documentation for more information
let unreliable = unreliable_sequenced;
let reliable_sequenced = reliable_sequenced;
let reliable_ordered = reliable_ordered;
// send the created packets
packet_sender.send.unwrap;
packet_sender.send.unwrap;
packet_sender.send.unwrap;
packet_sender.send.unwrap;
packet_sender.send.unwrap;
Receive Packets
use ;
// create the socket
let = bind?;
// this will start the socket, which will start a poll mechanism to receive and send messages.
let _thread = spawn;
// wait until a socket event occurs
let result = packet_receiver.recv;
match result
Authors
Note
This library is not fully stable yet, and there may be breaking changes to the API. For more advanced examples of using laminar, you can check out the Amethyst-Network crate.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.